import Home from '@/views/Home'
import Search from '@/views/Search'
import NotFound from '@/views/NotFound'
import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter) // VueRouter插件初始化

// 创建了一个路由对象
/*
Vue路由 - 模式设置
  问题:路由的路径看起来不自然有#，能否切成真正路径形式?
    hash路由(默认)例如: http://localhost:8080/#/home
    history路由(常用)例如: http://localhost:8080/home (以后上线需要服务器端支持)
*/
const router = new VueRouter({
  routes: [
    { path: '/', redirect: '/home' },
    { path: '/home', component: Home },
    { path: '/search/:key?', component: Search },
    { path: '*', component: NotFound },
  ],
  mode: 'history'
})

export default router